<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Eigenmath Help</title>
</head>
<body style="font-size:16pt">

<table style="font-family:courier;width:100%">
<tr>

<td>
<a href="#abs">abs</a><br>
<a href="#adj">adj</a><br>
<a href="#and">and</a><br>
<a href="#arccos">arccos</a><br>
<a href="#arccosh">arccosh</a><br>
<a href="#arcsin">arcsin</a><br>
<a href="#arcsinh">arcsinh</a><br>
<a href="#arctan">arctan</a><br>
<a href="#arctanh">arctanh</a><br>
<a href="#arg">arg</a><br>
<a href="#binding">binding</a><br>
<a href="#ceiling">ceiling</a><br>
<a href="#check">check</a><br>
<a href="#circexp">circexp</a><br>
<a href="#clear">clear</a><br>
</td>

<td>
<a href="#clock">clock</a><br>
<a href="#cofactor">cofactor</a><br>
<a href="#conj">conj</a><br>
<a href="#contract">contract</a><br>
<a href="#cos">cos</a><br>
<a href="#cosh">cosh</a><br>
<a href="#d">d</a><br>
<a href="#defint">defint</a><br>
<a href="#denominator">denominator</a><br>
<a href="#det">det</a><br>
<a href="#dim">dim</a><br>
<a href="#do">do</a><br>
<a href="#dot">dot</a><br>
<a href="#draw">draw</a><br>
<a href="#eigenvec">eigenvec</a><br>
</td>

<td>
<a href="#eval">eval</a><br>
<a href="#exp">exp</a><br>
<a href="#expcos">expcos</a><br>
<a href="#expcosh">expcosh</a><br>
<a href="#expsin">expsin</a><br>
<a href="#expsinh">expsinh</a><br>
<a href="#exptan">exptan</a><br>
<a href="#exptanh">exptanh</a><br>
<a href="#factorial">factorial</a><br>
<a href="#float">float</a><br>
<a href="#floor">floor</a><br>
<a href="#for">for</a><br>
<a href="#hadamard">hadamard</a><br>
<a href="#i">i</a><br>
<a href="#imag">imag</a><br>
</td>

<td>
<a href="#infixform">infixform</a><br>
<a href="#inner">inner</a><br>
<a href="#integral">integral</a><br>
<a href="#inv">inv</a><br>
<a href="#j">j</a><br>
<a href="#kronecker">kronecker</a><br>
<a href="#last">last</a><br>
<a href="#log">log</a><br>
<a href="#mag">mag</a><br>
<a href="#minor">minor</a><br>
<a href="#minormatrix">minormatrix</a><br>
<a href="#mod">mod</a><br>
<a href="#noexpand">noexpand</a><br>
<a href="#not">not</a><br>
<a href="#nroots">nroots</a><br>
</td>

<td>
<a href="#numerator">numerator</a><br>
<a href="#or">or</a><br>
<a href="#outer">outer</a><br>
<a href="#pi">pi</a><br>
<a href="#polar">polar</a><br>
<a href="#power">power</a><br>
<a href="#print">print</a><br>
<a href="#product">product</a><br>
<a href="#quote">quote</a><br>
<a href="#rank">rank</a><br>
<a href="#rationalize">rationalize</a><br>
<a href="#real">real</a><br>
<a href="#rect">rect</a><br>
<a href="#roots">roots</a><br>
<a href="#rotate">rotate</a><br>
</td>

<td>
<a href="#run">run</a><br>
<a href="#simplify">simplify</a><br>
<a href="#sin">sin</a><br>
<a href="#sinh">sinh</a><br>
<a href="#sqrt">sqrt</a><br>
<a href="#stop">stop</a><br>
<a href="#sum">sum</a><br>
<a href="#tan">tan</a><br>
<a href="#tanh">tanh</a><br>
<a href="#taylor">taylor</a><br>
<a href="#test">test</a><br>
<a href="#trace">trace</a><br>
<a href="#transpose">transpose</a><br>
<a href="#unit">unit</a><br>
<a href="#zero">zero</a><br>
</td>

</tr>
</table>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="abs">abs(<i>x</i>)</a>
<p>
Returns the absolute value or vector length of <i>x</i>.
<pre style="font-family:courier;color:blue">
X = (x,y,z)
abs(X)
</pre>
<pre style="font-family:courier">
┌            ┐1/2
│ 2    2    2│   
│x  + y  + z │   
│            │   
└            ┘   
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="adj">adj(<i>m</i>)</a>
<p>
Returns the adjunct of matrix <i>m</i>.
Adjunct is equal to determinant times inverse.
</p>
<pre style="font-family:courier;color:blue">
A = ((a,b),(c,d))
adj(A) == det(A) inv(A)
</pre>
<pre style="font-family:courier">
1
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="and">and(<i>a,b,...</i>)</a>
<p>
Returns 1 if all arguments are true (nonzero).
Returns 0 otherwise.
<pre style="font-family:courier;color:blue">
and(1=1,2=2)
</pre>
<pre style="font-family:courier">
1
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="arccos">arccos(<i>x</i>)</a>
<p>
Returns the arc cosine of <i>x</i>.
<pre style="font-family:courier;color:blue">
arccos(1/2)
</pre>
<pre style="font-family:courier">
 1   
╶─╴ π
 3   
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="arccosh">arccosh(<i>x</i>)</a>
<p>
Returns the arc hyperbolic cosine of <i>x</i>.

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="arcsin">arcsin(<i>x</i>)</a>
<p>
Returns the arc sine of <i>x</i>.
<pre style="font-family:courier;color:blue">
arcsin(1/2)
</pre>
<pre style="font-family:courier">
 1   
╶─╴ π
 6   
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="arcsinh">arcsinh(<i>x</i>)</a>
<p>
Returns the arc hyperbolic sine of <i>x</i>.

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="arctan">arctan(<i>y,x</i>)</a>
<p>
Returns the arc tangent of <i>y</i> over <i>x</i>.
If <i>x</i> is omitted then <i>x</i> = 1 is used.
<pre style="font-family:courier;color:blue">
arctan(1,0)
</pre>
<pre style="font-family:courier">
 1   
╶─╴ π
 2   
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="arctanh">arctanh(<i>x</i>)</a>
<p>
Returns the arc hyperbolic tangent of <i>x</i>.

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="arg">arg(<i>z</i>)</a>
<p>
Returns the angle of complex <i>z</i>.
<pre style="font-family:courier;color:blue">
arg(2 - 3i)
</pre>
<pre style="font-family:courier">
arctan(-3,2)
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="binding">binding(<i>s</i>)</a>
<p>
The result of evaluating a symbol can differ from the symbol's binding.
For example, the result may be expanded.
The
<span style="font-family:courier">binding</span>
function returns the actual binding of a symbol.
<pre style="font-family:courier;color:blue">
p = quote((x + 1)^2)
p
</pre>
<pre style="font-family:courier">
     2
p = x  + 2 x + 1
</pre>
<pre style="font-family:courier;color:blue">
binding(p)
</pre>
<pre style="font-family:courier">
       2
(x + 1)
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="ceiling">ceiling(<i>x</i>)</a>
<p>
Returns the smallest integer greater than or equal to <i>x</i>.
<pre style="font-family:courier;color:blue">
ceiling(1/2)
</pre>
<pre style="font-family:courier">
1
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="check">check(<i>x</i>)</a>
<p>
If <i>x</i> is true (nonzero) then continue in a script, else stop.
Expression <i>x</i> can include the relational operators
<span style="font-family:courier">=</span>,
<span style="font-family:courier">==</span>,
<span style="font-family:courier">&lt;</span>,
<span style="font-family:courier">&lt;=</span>,
<span style="font-family:courier">&gt;</span>,
<span style="font-family:courier">&gt;=</span>.
Use the
<span style="font-family:courier">not</span>
function to test for inequality.
<pre style="font-family:courier;color:blue">
A = exp(i pi)
B = -1
check(A == B) -- stop here if A not equal to B
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="circexp">circexp(<i>x</i>)</a>
<p>
Returns expression <i>x</i> with circular and hyperbolic functions converted to exponentials.
<pre style="font-family:courier;color:blue">
circexp(cos(x) + i sin(x))
</pre>
<pre style="font-family:courier">
exp(i x)
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="clear">clear</a>
<p>
Clears all symbol definitions.

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="clock">clock(z)</a>
<p>
Returns complex <i>z</i> in polar form with base of negative 1 instead of <i>e</i>.
<pre style="font-family:courier;color:blue">
clock(2 - 3i)
</pre>
<pre style="font-family:courier">
           arctan(−3,2) 
          ╶────────────╴
  1/2           π       
13    (−1)              
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="cofactor">cofactor(<i>m,i,j</i>)</a>
<p>
Returns the cofactor of matrix <i>m</i> for row <i>i</i> and column <i>j</i>.
<pre style="font-family:courier;color:blue">
A = ((a,b),(c,d))
cofactor(A,1,2) == adj(A)[2,1]
</pre>
<pre style="font-family:courier">
1
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="conj">conj(<i>z</i>)</a>
<p>
Returns the complex conjugate of <i>z</i>.
<pre style="font-family:courier;color:blue">
conj(2 - 3i)
</pre>
<pre style="font-family:courier">
2 + 3 i
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="contract">contract(<i>a,i,j</i>)</a>
<p>
Returns tensor <i>a</i> summed over indices <i>i</i> and <i>j</i>.
If <i>i</i> and <i>j</i> are omitted then 1 and 2 are used.
The expression
<span style="font-family:courier">contract(m)</span>
computes the trace of matrix <i>m</i>.
<pre style="font-family:courier;color:blue">
A = ((a,b),(c,d))
contract(A)
</pre>
<pre style="font-family:courier">
a + d
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="cos">cos(<i>x</i>)</a>
<p>
Returns the cosine of <i>x</i>.
<pre style="font-family:courier;color:blue">
cos(pi/4)
</pre>
<pre style="font-family:courier">
  1   
╶────╴
  1/2 
 2    
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="cosh">cosh(<i>x</i>)</a>
<p>
Returns the hyperbolic cosine of <i>x</i>.
<pre style="font-family:courier;color:blue">
circexp(cosh(x))
</pre>
<pre style="font-family:courier">
 1             1        
╶─╴ exp(−x) + ╶─╴ exp(x)
 2             2        
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="d">d(<i>f,x</i>)</a>
<p>
Returns the partial derivative of <i>f</i> with respect to <i>x</i>.
<pre style="font-family:courier;color:blue">
d(x^2,x)
</pre>
<pre style="font-family:courier">
2 x
</pre>
<p>
Argument <i>f</i> can be a tensor of any rank.
Argument <i>x</i> can be a vector.
When <i>x</i> is a vector the result is the gradient of <i>f</i>.
<pre style="font-family:courier;color:blue">
F = (f(),g(),h())
X = (x,y,z)
d(F,X)
</pre>
<pre style="font-family:courier">
┌                                ┐
│ d(f(),x)   d(f(),y)   d(f(),z) │
│                                │
│ d(g(),x)   d(g(),y)   d(g(),z) │
│                                │
│ d(h(),x)   d(h(),y)   d(h(),z) │
└                                ┘
</pre>
<p>
It is OK to use
<span style="font-family:courier">d</span>
as a variable name.
It will not conflict with function
<span style="font-family:courier">d</span>.
<p>
It is OK to redefine
<span style="font-family:courier">d</span>
as a different function.
The function
<span style="font-family:courier">derivative</span>,
a synonym for
<span style="font-family:courier">d</span>,
can still be used to obtain a partial derivative.

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="defint">defint(<i>f,x,a,b</i>)</a>
<p>
Returns the definite integral of <i>f</i> with respect to <i>x</i>
evaluated from <i>a</i> to <i>b</i>.
The argument list can be extended for multiple integrals as shown in the following example.
<pre style="font-family:courier;color:blue">
f = (1 + cos(theta)^2) sin(theta)
defint(f, theta, 0, pi, phi, 0, 2 pi) -- integrate over theta then over phi
</pre>
<pre style="font-family:courier">
 16   
╶──╴ π
 3    
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="denominator">denominator(<i>x</i>)</a>
<p>
Returns the denominator of expression <i>x</i>.
<pre style="font-family:courier;color:blue">
denominator(a/b)
</pre>
<pre style="font-family:courier">
b
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="det">det(<i>m</i>)</a>
<p>
Returns the determinant of matrix <i>m</i>.
<pre style="font-family:courier;color:blue">
A = ((a,b),(c,d))
det(A)
</pre>
<pre style="font-family:courier">
a d - b c
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="dim">dim(<i>a,n</i>)</a>
<p>
Returns the dimension of the <i>n</i>th index of tensor <i>a</i>.
Index numbering starts with 1.
<pre style="font-family:courier;color:blue">
A = ((1,2),(3,4),(5,6))
dim(A,1)
</pre>
<pre style="font-family:courier">
3
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="do">do(<i>a,b,...</i>)</a>
<p>
Evaluates each argument from left to right.
Returns the result of the final argument.
<pre style="font-family:courier;color:blue">
do(A=1,B=2,A+B)
</pre>
<pre style="font-family:courier">
3
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="dot">dot(<i>a,b,...</i>)</a>
<p>
Returns the dot product of vectors, matrices, and tensors.
Also known as the matrix product.
Arguments are evaluated from right to left.
The following example solves for <i>X</i> in <i>AX</i> = <i>B</i>.
<pre style="font-family:courier;color:blue">
A = ((1,2),(3,4))
B = (5,6)
X = dot(inv(A),B)
X
</pre>
<pre style="font-family:courier">
    ┌     ┐
    │ −4  │
    │     │
X = │  9  │
    │ ╶─╴ │
    │  2  │
    └     ┘
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="draw">draw(<i>f,x</i>)</a>
<p>
Draws a graph of <i>f</i>(<i>x</i>).
Drawing ranges can be set with
<span style="font-family:courier">xrange</span>
and
<span style="font-family:courier">yrange</span>.
<pre style="font-family:courier;color:blue">
xrange = (0,1)
yrange = (0,1)
draw(x^2,x)
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="eigenvec">eigenvec(<i>m</i>)</a>
<p>
Returns eigenvectors for matrix <i>m</i>.
Matrix <i>m</i> is required to be numerical, real, and symmetric.
The return value is a matrix with each column an eigenvector.
Eigenvalues are obtained as shown.
<pre style="font-family:courier;color:blue">
A = ((1,2,3),(2,6,4),(3,4,5))
Q = eigenvec(A)
D = dot(transpose(Q),A,Q) -- eigenvalues are on the diagonal of D
dot(Q,D,transpose(Q))
</pre>
<pre style="font-family:courier">
┌           ┐
│ 1   2   3 │
│           │
│ 2   6   4 │
│           │
│ 3   4   5 │
└           ┘
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="eval">eval(<i>f,x,a</i>)</a>
<p>
Returns expression <i>f</i> evaluated at <i>x</i> equals <i>a</i>.
The argument list can be extended as shown.
<pre style="font-family:courier;color:blue">
f = sqrt(x^2 + y^2)
eval(f,x,3,y,4) -- evaluate f at x=3 and y=4
</pre>
<pre style="font-family:courier">
5
</pre>
<p>
In the following example,
<span style="font-family:courier">eval</span>
is used to compute an associated Legendre function of
<span style="font-family:courier">expcos(theta)</span>.
<pre style="font-family:courier;color:blue">
P(x,n,m) = 1/(2^n n!) (1-x^2)^(m/2) d((x^2-1)^n,x,n+m)
Pf(f,n,m) = eval(P(x,n,m),x,f)
Pf(expcos(theta),2,0)
</pre>
<pre style="font-family:courier">
 3                3                 1 
╶─╴ exp(2 i θ) + ╶─╴ exp(−2 i θ) + ╶─╴
 8                8                 4 
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="exp">exp(<i>x</i>)</a>
<p>
Returns the exponential of <i>x</i>.
<pre style="font-family:courier;color:blue">
exp(i pi)
</pre>
<pre style="font-family:courier">
-1
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="expcos">expcos(<i>z</i>)</a>
<p>
Returns the cosine of <i>z</i> in exponential form.
<pre style="font-family:courier;color:blue">
expcos(z)
</pre>
<pre style="font-family:courier">
 1              1           
╶─╴ exp(i z) + ╶─╴ exp(−i z)
 2              2           
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="expcosh">expcosh(<i>z</i>)</a>
<p>
Returns the hyperbolic cosine of <i>z</i> in exponential form.
<pre style="font-family:courier;color:blue">
expcosh(z)
</pre>
<pre style="font-family:courier">
 1             1        
╶─╴ exp(−z) + ╶─╴ exp(z)
 2             2        
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="expsin">expsin(<i>z</i>)</a>
<p>
Returns the sine of <i>z</i> in exponential form.
<pre style="font-family:courier;color:blue">
expsin(z)
</pre>
<pre style="font-family:courier">
  1                1             
−╶─╴ i exp(i z) + ╶─╴ i exp(−i z)
  2                2             
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="expsinh">expsinh(<i>z</i>)</a>
<p>
Returns the hyperbolic sine of <i>z</i> in exponential form.
<pre style="font-family:courier;color:blue">
expsinh(z)
</pre>
<pre style="font-family:courier">
  1             1        
−╶─╴ exp(−z) + ╶─╴ exp(z)
  2             2        
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="exptan">exptan(<i>z</i>)</a>
<p>
Returns the tangent of <i>z</i> in exponential form.
<pre style="font-family:courier;color:blue">
exptan(z)
</pre>
<pre style="font-family:courier">
       i             i exp(2 i z)  
╶──────────────╴ − ╶──────────────╴
 exp(2 i z) + 1     exp(2 i z) + 1 
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="exptanh">exptanh(<i>z</i>)</a>
<p>
Returns the hyperbolic tangent of <i>z</i> in exponential form.
<pre style="font-family:courier;color:blue">
exptanh(z)
</pre>
<pre style="font-family:courier">
       1             exp(2 z)   
−╶────────────╴ + ╶────────────╴
  exp(2 z) + 1     exp(2 z) + 1 
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="factorial">factorial(<i>n</i>)</a>
<p>
Returns the factorial of <i>n</i>.
The expression
<span style="font-family:courier">n!</span>
can also be used.
<pre style="font-family:courier;color:blue">
20!
</pre>
<pre style="font-family:courier">
2432902008176640000
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="float">float(<i>x</i>)</a>
<p>
Returns expression <i>x</i> with rational numbers and integers converted to
floating point values.
The symbol
<span style="font-family:courier">pi</span>
and the natural number are also converted.
<pre style="font-family:courier;color:blue">
float(212^17)
</pre>
<pre style="font-family:courier">
          39
3.52947 10
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="floor">floor(<i>x</i>)</a>
<p>
Returns the largest integer less than or equal to <i>x</i>.
<pre style="font-family:courier;color:blue">
floor(1/2)
</pre>
<pre style="font-family:courier">
0
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="for">for(<i>i,j,k,a,b,...</i>)</a>
<p>
For <i>i</i> equals <i>j</i> through <i>k</i> evaluate <i>a</i>, <i>b</i>, etc.
<pre style="font-family:courier;color:blue">
for(k,1,3,A=k,print(A))
</pre>
<pre style="font-family:courier">
A = 1
A = 2
A = 3
</pre>
<p>
Note:
The original value of <i>i</i> is restored after
<span style="font-family:courier">for</span>
completes.
If symbol
<span style="font-family:courier">i</span>
is used for index variable <i>i</i> then the imaginary unit is overridden in the scope of
<span style="font-family:courier">for</span>.

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="hadamard">hadamard(<i>a,b,...</i>)</a>
<p>
Returns the Hadamard (element-wise) product.
The arguments are required to have the same dimensions.
The Hadamard product is also accomplished by simply multiplying the arguments.
<pre style="font-family:courier;color:blue">
A = ((A11,A12),(A21,A22))
B = ((B11,B12),(B21,B22))
A B
</pre>
<pre style="font-family:courier">
┌                   ┐
│ A   B     A   B   │
│  11  11    12  12 │
│                   │
│ A   B     A   B   │
│  21  21    22  22 │
└                   ┘
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="i">i</a>
<p>
Symbol
<span style="font-family:courier">i</span>
is initialized to the imaginary unit (&minus;1)<sup>1/2</sup>.
<pre style="font-family:courier;color:blue">
exp(i pi)
</pre>
<pre style="font-family:courier">
-1
</pre>
<p>
Note:
It is OK to clear or redefine
<span style="font-family:courier">i</span>
and use the symbol for something else.

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="imag">imag(<i>z</i>)</a>
<p>
Returns the imaginary part of complex <i>z</i>.
<pre style="font-family:courier;color:blue">
imag(2 - 3i)
</pre>
<pre style="font-family:courier">
-3
</pre>


<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="infixform">infixform(<i>x</i>)</a>
<p>
Converts expression <i>x</i> to a string and returns the result.
<pre style="font-family:courier;color:blue">
p = (x + 1)^2
infixform(p)
</pre>
<pre style="font-family:courier">
x^2 + 2 x + 1
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="inner">inner(<i>a,b,...</i>)</a>
<p>
Returns the inner product of vectors, matrices, and tensors.
Also known as the matrix product.
Arguments are evaluated from right to left.
<pre style="font-family:courier;color:blue">
A = ((a,b),(c,d))
B = (x,y)
inner(A,B)
</pre>
<pre style="font-family:courier">
┌           ┐
│ a x + b y │
│           │
│ c x + d y │
└           ┘
</pre>
<p>
Note:
<span style="font-family:courier">inner</span>
and
<span style="font-family:courier">dot</span>
are the same function.

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="integral">integral(<i>f,x</i>)</a>
<p>
Returns the integral of <i>f</i> with respect to <i>x</i>.
<pre style="font-family:courier;color:blue">
integral(x^2,x)
</pre>
<pre style="font-family:courier">
 1   3
╶─╴ x 
 3    
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="inv">inv(<i>m</i>)</a>
<p>
Returns the inverse of matrix <i>m</i>.
<pre style="font-family:courier;color:blue">
A = ((1,2),(3,4))
inv(A)
</pre>
<pre style="font-family:courier">
┌            ┐
│ −2     1   │
│            │
│  3      1  │
│ ╶─╴   −╶─╴ │
│  2      2  │
└            ┘
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="j">j</a>
<p>
Set
<span style="font-family:courier">j=sqrt(-1)</span>
to use
<span style="font-family:courier">j</span>
for the imaginary unit instead of
<span style="font-family:courier">i</span>.
<pre style="font-family:courier;color:blue">
j = sqrt(-1)
1/sqrt(-1)
</pre>
<pre style="font-family:courier">
-j
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="kronecker">kronecker(<i>a,b,...</i>)</a>
<p>
Returns the Kronecker product of vectors and matrices.
<pre style="font-family:courier;color:blue">
A = ((1,2),(3,4))
B = ((a,b),(c,d))
kronecker(A,B)
</pre>
<pre style="font-family:courier">
┌                       ┐
│  a     b    2 a   2 b │
│                       │
│  c     d    2 c   2 d │
│                       │
│ 3 a   3 b   4 a   4 b │
│                       │
│ 3 c   3 d   4 c   4 d │
└                       ┘
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="last">last</a>
<p>
The result of the previous calculation is stored in
<span style="font-family:courier">last</span>.
<pre style="font-family:courier;color:blue">
212^17
</pre>
<pre style="font-family:courier">
3529471145760275132301897342055866171392
</pre>
<pre style="font-family:courier;color:blue">
last^(1/17)
</pre>
<pre style="font-family:courier">
212
</pre>
<p>
Note:
Symbol
<span style="font-family:courier">last</span>
is an implied argument when a function has no argument list.
<pre style="font-family:courier;color:blue">
212^17
</pre>
<pre style="font-family:courier">
3529471145760275132301897342055866171392
</pre>
<pre style="font-family:courier;color:blue">
float
</pre>
<pre style="font-family:courier">
          39
3.52947 10
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="log">log(<i>x</i>)</a>
<p>
Returns the natural logarithm of <i>x</i>.
<pre style="font-family:courier;color:blue">
log(x^y)
</pre>
<pre style="font-family:courier">
y log(x)
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="mag">mag(<i>z</i>)</a>
<p>
Returns the magnitude of complex <i>z</i>.
<pre style="font-family:courier;color:blue">
mag(x + i y)
</pre>
<pre style="font-family:courier">
┌       ┐1/2
│ 2    2│   
│x  + y │   
│       │   
└       ┘   
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="minor">minor(<i>m,i,j</i>)</a>
<p>
Returns the minor of matrix <i>m</i> for row <i>i</i> and column <i>j</i>.
<pre style="font-family:courier;color:blue">
A = ((1,2,3),(4,5,6),(7,8,9))
minor(A,1,1) == det(minormatrix(A,1,1))
</pre>
<pre style="font-family:courier">
1
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="minormatrix">minormatrix(<i>m,i,j</i>)</a>
<p>
Returns a copy of matrix <i>m</i> with row <i>i</i> and column <i>j</i> removed.
<pre style="font-family:courier;color:blue">
A = ((1,2,3),(4,5,6),(7,8,9))
minormatrix(A,1,1)
</pre>
<pre style="font-family:courier">
┌       ┐
│ 5   6 │
│       │
│ 8   9 │
└       ┘
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="mod">mod(<i>a,b</i>)</a>
<p>
Returns the remainder of <i>a</i> over <i>b</i>.
<pre style="font-family:courier;color:blue">
mod(5,3/8)
</pre>
<pre style="font-family:courier">
 1 
╶─╴
 8 
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="noexpand">noexpand(<i>x</i>)</a>
<p>
Evaluates expression <i>x</i> without expanding products of sums.
<pre style="font-family:courier;color:blue">
noexpand((x + 1)^2 / (x + 1))
</pre>
<pre style="font-family:courier">
x + 1
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="not">not(<i>x</i>)</a>
<p>
Returns 0 if <i>x</i> is true (nonzero).
Returns 1 otherwise.
<pre style="font-family:courier;color:blue">
not(1=1)
</pre>
<pre style="font-family:courier">
0
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="nroots">nroots(<i>p,x</i>)</a>
<p>
Returns the approximate roots of polynomials with real or complex coefficients.
Multiple roots are returned as a vector.
See also <a href="#roots">roots</a>.
<pre style="font-family:courier;color:blue">
p = x^5 - 1
nroots(p,x)
</pre>
<pre style="font-family:courier">
┌                        ┐
│           1            │
│                        │
│ −0.809017 + 0.587785 i │
│                        │
│ −0.809017 − 0.587785 i │
│                        │
│ 0.309017 + 0.951057 i  │
│                        │
│ 0.309017 − 0.951057 i  │
└                        ┘
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="numerator">numerator(<i>x</i>)</a>
<p>
Returns the numerator of expression <i>x</i>.
<pre style="font-family:courier;color:blue">
numerator(a/b)
</pre>
<pre style="font-family:courier">
a
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="or">or(<i>a,b,...</i>)</a>
<p>
Returns 1 if at least one argument is true (nonzero).
Returns 0 otherwise.
<pre style="font-family:courier;color:blue">
or(1=1,2=2)
</pre>
<pre style="font-family:courier">
1
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="outer">outer(<i>a,b,...</i>)</a>
<p>
Returns the outer product of vectors, matrices, and tensors.
<pre style="font-family:courier;color:blue">
A = (a,b,c)
B = (x,y,z)
outer(A,B)
</pre>
<pre style="font-family:courier">
┌                 ┐
│ a x   a y   a z │
│                 │
│ b x   b y   b z │
│                 │
│ c x   c y   c z │
└                 ┘
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="pi">pi</a>
<p>
Symbol for &#960;.
<pre style="font-family:courier;color:blue">
exp(i pi)
</pre>
<pre style="font-family:courier">
-1
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="polar">polar(<i>z</i>)</a>
<p>
Returns complex <i>z</i> in polar form.
<pre style="font-family:courier;color:blue">
polar(x - i y)
</pre>
<pre style="font-family:courier">
┌       ┐1/2                    
│ 2    2│                       
│x  + y │    exp(i arctan(−y,x))
│       │                       
└       ┘                       
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="power">power</a>
<p>
Use
<span style="font-family:courier">^</span>
to raise something to a power.
Use parentheses for negative powers.
<pre style="font-family:courier;color:blue">
x^(-1/2)
</pre>
<pre style="font-family:courier">
  1   
╶────╴
  1/2 
 x    
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="print">print(<i>a,b,...</i>)</a>
<p>
Evaluate expressions and print the results.
Useful for printing from inside a
<span style="font-family:courier">for</span>
loop.
<pre style="font-family:courier;color:blue">
for(j,1,3,print(j))
</pre>
<pre style="font-family:courier">
j = 1
j = 2
j = 3
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="product">product(<i>i,j,k,f</i>)</a>
<p>
For <i>i</i> equals <i>j</i> through <i>k</i> evaluate <i>f</i>.
Returns the product of all <i>f</i>.
<pre style="font-family:courier;color:blue">
product(j,1,3,x + j)
</pre>
<pre style="font-family:courier">
 3      2
x  + 6 x  + 11 x + 6
</pre>
<p>
The original value of <i>i</i> is restored after
<span style="font-family:courier">product</span>
completes.
If symbol
<span style="font-family:courier">i</span>
is used for index variable <i>i</i> then the imaginary unit is overridden in the scope of
<span style="font-family:courier">product</span>.

<p style="font-family:courier;font-size:24pt;font-weight:bold">
product(<i>y</i>)
<p>
Returns the product of components of <i>y</i>.
<pre style="font-family:courier;color:blue">
y = (1,2,3,4)
product(y)
</pre>
<pre style="font-family:courier">
24
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="quote">quote(<i>x</i>)</a>
<p>
Returns expression <i>x</i> without evaluating it first.
<pre style="font-family:courier;color:blue">
quote((x + 1)^2)
</pre>
<pre style="font-family:courier">
       2
(x + 1)
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="rank">rank(<i>a</i>)</a>
<p>
Returns the number of indices that tensor <i>a</i> has.
<pre style="font-family:courier;color:blue">
A = ((a,b),(c,d))
rank(A)
</pre>
<pre style="font-family:courier">
2
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="rationalize">rationalize(<i>x</i>)</a>
<p>
Returns expression <i>x</i> with everything over a common denominator.
<pre style="font-family:courier;color:blue">
rationalize(1/a + 1/b + 1/2)
</pre>
<pre style="font-family:courier">
 2 a + a b + 2 b 
╶───────────────╴
      2 a b      
</pre>
<p>
Note:
<span style="font-family:courier">rationalize</span>
returns an unexpanded expression.
If the result is assigned to a symbol, evaluating the symbol will expand the result.
Use
<span style="font-family:courier">binding</span>
to retrieve the unexpanded expression.
<pre style="font-family:courier;color:blue">
f = rationalize(1/a + 1/b + 1/2)
binding(f)
</pre>
<pre style="font-family:courier">
 2 a + a b + 2 b 
╶───────────────╴
      2 a b      
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="real">real(<i>z</i>)</a>
<p>
Returns the real part of complex <i>z</i>.
<pre style="font-family:courier;color:blue">
real(2 - 3i)
</pre>
<pre style="font-family:courier">
2
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="rect">rect(<i>z</i>)</a>
<p>
Returns complex <i>z</i> in rectangular form.
<pre style="font-family:courier;color:blue">
rect(exp(i x))
</pre>
<pre style="font-family:courier">
cos(x) + i sin(x)
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="roots">roots(<i>p,x</i>)</a>
<p>
Returns the rational roots of a polynomial.
Multiple roots are returned as a vector.
See also <a href="#nroots">nroots</a>.
<pre style="font-family:courier;color:blue">
p = (x + 1) (x - 2)
roots(p,x)
</pre>
<pre style="font-family:courier">
┌    ┐
│ −1 │
│    │
│ 2  │
└    ┘
</pre>

<p>
If no roots are found then
<span style="font-family:courier">nil</span>
is returned.
A
<span style="font-family:courier">nil</span>
result prints as blank so the following example uses
<span style="font-family:courier">infixform</span>
to print
<span style="font-family:courier">nil</span>
as a string.
<pre style="font-family:courier;color:blue">
p = x^2 + 1
infixform(roots(p,x))
</pre>
<pre style="font-family:courier">
nil
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="rotate">rotate(<i>u,s,k,...</i>)</a>
<p>
Rotates vector <i>u</i> and returns the result.
Vector <i>u</i> is required to have 2<sup><i>n</i></sup> elements
where <i>n</i> is an integer from 1 to 15.
Arguments <i>s,k,...</i> are a sequence of rotation codes
where <i>s</i> is an upper case letter and <i>k</i> is a qubit number
0 to <i>n</i> &minus; 1.
Rotations are evaluated from left to right.
The available rotations are
<table>
<tr><td>C, <i>k</i></td><td>Control prefix</td></tr>

<tr><td>H, <i>k</i></td><td>Hadamard</td></tr>

<tr><td>P, <i>k, &phi;</i></td><td>Phase modifier (use <i>&phi;</i> = 1/4 <i>&pi;</i> for T rotation)</td></tr>

<tr><td>Q, <i>k</i></td><td>Quantum Fourier transform</td></tr>

<tr><td>V, <i>k</i></td><td>Inverse quantum Fourier transform</td></tr>

<tr><td>W, <i>k, j</i>&nbsp;</td><td>Swap qubits</td></tr>

<tr><td>X, <i>k</i></td><td>Pauli X</td></tr>

<tr><td>Y, <i>k</i></td><td>Pauli Y</td></tr>

<tr><td>Z, <i>k</i></td><td>Pauli Z</td></tr>
</table>
<p>
Control prefix C, <i>k</i> modifies the next rotation code so that it is
a controlled rotation with <i>k</i> as the control qubit.
Use two or more prefixes to specify multiple control qubits.
For example, C, <i>k</i>, C, <i>j</i>, X, <i>m</i> is a Toffoli rotation.
Fourier rotations Q, <i>k</i> and V, <i>k</i> are applied
to qubits 0 through <i>k</i>.
(Q and V ignore any control prefix.)
See also section 3 of the Eigenmath manual.
<pre style="font-family:courier;color:blue">
psi = (1,0,0,0)
rotate(psi,H,0)
</pre>
<pre style="font-family:courier">
┌        ┐
│   1    │
│ ╶────╴ │
│   1/2  │
│  2     │
│        │
│   1    │
│ ╶────╴ │
│   1/2  │
│  2     │
│        │
│   0    │
│        │
│   0    │
└        ┘
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="run">run(<i>x</i>)</a>
<p>
Run script <i>x</i> where <i>x</i> evaluates to a filename string.
Useful for importing function libraries.
<pre style="font-family:courier;color:blue">
run("EVA2.txt")
</pre>
<p>
For Eigenmath installed from the Mac App Store, run files must be put in the directory Library/Containers/com.gweigt.eigenmath/Data/

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="simplify">simplify(<i>x</i>)</a>
<p>
Returns expression <i>x</i> in a simpler form.
<pre style="font-family:courier;color:blue">
simplify(sin(x)^2 + cos(x)^2)
</pre>
<pre style="font-family:courier">
1
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="sin">sin(<i>x</i>)</a>
<p>
Returns the sine of <i>x</i>.
<pre style="font-family:courier;color:blue">
sin(pi/4)
</pre>
<pre style="font-family:courier">
  1   
╶────╴
  1/2 
 2    
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="sinh">sinh(<i>x</i>)</a>
<p>
Returns the hyperbolic sine of <i>x</i>.
<pre style="font-family:courier;color:blue">
circexp(sinh(x))
</pre>
<pre style="font-family:courier">
  1             1        
−╶─╴ exp(−x) + ╶─╴ exp(x)
  2             2        
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="sqrt">sqrt(<i>x</i>)</a>
<p>
Returns the square root of <i>x</i>.
<pre style="font-family:courier;color:blue">
sqrt(10!)
</pre>
<pre style="font-family:courier">
     1/2
720 7
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="stop">stop</a>
<p>
In a script, it does what it says.

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="sum">sum(<i>i,j,k,f</i>)</a>
<p>
For <i>i</i> equals <i>j</i> through <i>k</i> evaluate <i>f</i>.
Returns the sum of all <i>f</i>.
<pre style="font-family:courier;color:blue">
sum(j,1,5,x^j)
</pre>
<pre style="font-family:courier">
 5    4    3    2
x  + x  + x  + x  + x
</pre>
<p>
The original value of <i>i</i> is restored after
<span style="font-family:courier">sum</span>
completes.
If symbol
<span style="font-family:courier">i</span>
is used for index variable <i>i</i> then the imaginary unit is overridden in the scope of
<span style="font-family:courier">sum</span>.

<p style="font-family:courier;font-size:24pt;font-weight:bold">
sum(<i>y</i>)
<p>
Returns the sum of components of <i>y</i>.
<pre style="font-family:courier;color:blue">
y = (1,2,3,4)
sum(y)
</pre>
<pre style="font-family:courier">
10
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="tan">tan(<i>x</i>)</a>
<p>
Returns the tangent of <i>x</i>.

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="tanh">tanh(<i>x</i>)</a>
<p>
Returns the hyperbolic tangent of <i>x</i>.
<pre style="font-family:courier;color:blue">
circexp(tanh(x))
</pre>
<pre style="font-family:courier">
       1             exp(2 x)   
−╶────────────╴ + ╶────────────╴
  exp(2 x) + 1     exp(2 x) + 1 
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="taylor">taylor(<i>f,x,n,a</i>)</a>
<p>
Returns the <i>n</i>th order Taylor series expansion of <i>f</i>(<i>x</i>) at <i>a</i>.
If argument <i>a</i> is omitted then zero is used for the expansion point.
<pre style="font-family:courier;color:blue">
taylor(1/(1-x),x,5)
</pre>
<pre style="font-family:courier">
 5    4    3    2        
x  + x  + x  + x  + x + 1
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="test">test(<i>a,b,c,d,...</i>)</a>
<p>
If argument <i>a</i> is true (nonzero) then <i>b</i> is returned, else if <i>c</i> is true then <i>d</i> is returned, etc.
If the number of arguments is odd then the final argument is returned if all else fails.
Expressions can include the relational operators
<span style="font-family:courier">=</span>,
<span style="font-family:courier">==</span>,
<span style="font-family:courier">&lt;</span>,
<span style="font-family:courier">&lt;=</span>,
<span style="font-family:courier">&gt;</span>,
<span style="font-family:courier">&gt;=</span>.
Use the
<span style="font-family:courier">not</span>
function to test for inequality.
(The equality operator
<span style="font-family:courier">==</span>
is available for contexts in which
<span style="font-family:courier">=</span>
is the assignment operator.)
<pre style="font-family:courier;color:blue">
A = 1
B = 1
test(A=B,"yes","no")
</pre>
<pre style="font-family:courier">
yes
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="trace">trace</a>
<p>
Set
<span style="font-family:courier">trace=1</span>
in a script to print the script as it is evaluated.
Useful for debugging.
<pre style="font-family:courier;color:blue">
trace = 1
</pre>
<p>
Note:
The
<span style="font-family:courier">contract</span>
function is used to obtain the trace of a matrix.

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="transpose">transpose(<i>a,i,j</i>)</a>
<p>
Returns the transpose of tensor <i>a</i> with respect to indices <i>i</i> and <i>j</i>.
If <i>i</i> and <i>j</i> are omitted then 1 and 2 are used.
Hence a matrix can be transposed with a single argument.
<pre style="font-family:courier;color:blue">
A = ((a,b),(c,d))
transpose(A)
</pre>
<pre style="font-family:courier">
┌       ┐
│ a   c │
│       │
│ b   d │
└       ┘
</pre>
<p>
Note:
The argument list can be extended for multiple transpose operations.
The arguments are evaluated from left to right.
For example,
<span style="font-family:courier">transpose(A,1,2,2,3)</span>
is equivalent to
<span style="font-family:courier">transpose(transpose(A,1,2),2,3)</span>.

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="unit">unit(<i>n</i>)</a>
<p>
Returns an <i>n</i> by <i>n</i> identity matrix.
<pre style="font-family:courier;color:blue">
unit(3)
</pre>
<pre style="font-family:courier">
┌           ┐
│ 1   0   0 │
│           │
│ 0   1   0 │
│           │
│ 0   0   1 │
└           ┘
</pre>

<p style="font-family:courier;font-size:24pt;font-weight:bold">
<a id="zero">zero(<i>i,j,...</i>)</a>
<p>
Returns a null tensor with dimensions <i>i</i>, <i>j</i>, etc.
Useful for creating a tensor and then setting the component values.
<pre style="font-family:courier;color:blue">
A = zero(3,3)
for(k,1,3,A[k,k]=k)
A
</pre>
<pre style="font-family:courier">
    ┌           ┐
    │ 1   0   0 │
    │           │
A = │ 0   2   0 │
    │           │
    │ 0   0   3 │
    └           ┘
</pre>

</body>
</html>
